/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package DataAccess;

import DataModel.Deportista;
import BussinesLogic.*;

public class Dao_Deportista {
    
    public Dao_Deportista(){}
    
    public Request registrarDeportista(Deportista deportista){
        
        String sql = "INSERT INTO \"Deportista\" (identificacion, estatura, peso, disciplina, foto, pais_rep)"
                + " VALUES('" + deportista.getIdentificacion() + "'," + deportista.getEstatura()
                + "," + deportista.getPeso() + ",'" + deportista.getDisciplina().getNombre()
                + "','" + deportista.getFoto() + "','" + deportista.getPaisRepresenta() + "')";
        
        Request request = new Request();

        try {
            Connect conn = new Connect();
            driverPGSQL driver = new driverPGSQL(conn);
            request = driver.queryInsert(sql);
            conn.close();
        } catch (Exception e) {
            request.setTransac(false);
            request.setMessage(e.getMessage());
        }
        return request;
    }
}
